import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StakingProductsVO, StakingProductsForm, StakingProductsQuery } from '@/api/business/stakingProducts/types';

/**
 * 查询质押产品列表
 * @param query
 * @returns {*}
 */

export const listStakingProducts = (query?: StakingProductsQuery): AxiosPromise<StakingProductsVO[]> => {
  return request({
    url: '/business/stakingProducts/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询质押产品详细
 * @param id
 */
export const getStakingProducts = (id: string | number): AxiosPromise<StakingProductsVO> => {
  return request({
    url: '/business/stakingProducts/' + id,
    method: 'get'
  });
};

/**
 * 新增质押产品
 * @param data
 */
export const addStakingProducts = (data: StakingProductsForm) => {
  return request({
    url: '/business/stakingProducts',
    method: 'post',
    data: data
  });
};

/**
 * 修改质押产品
 * @param data
 */
export const updateStakingProducts = (data: StakingProductsForm) => {
  return request({
    url: '/business/stakingProducts',
    method: 'put',
    data: data
  });
};

/**
 * 删除质押产品
 * @param id
 */
export const delStakingProducts = (id: string | number | Array<string | number>) => {
  return request({
    url: '/business/stakingProducts/' + id,
    method: 'delete'
  });
};

export const changeProductStatus = (id: string | number, status: number) => {
  const data = {
    id,
    status
  };
  return request({
    url: '/business/stakingProducts/changeProductStatus',
    method: 'put',
    data: data
  });
};

export const fundReward = (amount:any)=>{
  return request({
    url: '/business/stakingProducts/fundReward',
    method: 'post',
    data: {
      amount
    }
  });
}
